<template>
  <div class="wrap">
    <template class="d-flex align-items-center">
      <p><b>{{ $t('message.BeltDriveTool.inputParams') }}</b></p>
    </template>
    <template>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.drivingWheelDiameterCoefficient')}}:</label>
        <el-input v-model="params.drivingWheelDiameterCoefficient"
                  :step="100"
                  :min="1100"
                  :max="1300"
                  type = "number"
                  @change="changeDrivingWheelDiameterCoefficient"/>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.passingPower')}}:</label>
        <el-input v-model="params.P"
                  :step="1"
                  type = "number"
                  @change="changeP"/>
        <label class="el-form-item__label">kW</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.drivingWheelRotateSpeed')}}:</label>
        <el-input v-model="params.n1"
                  :step="100"
                  type = "number"
                  @change="changeP"/>
        <label class="el-form-item__label">r/min</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.drivenWheelRotateSpeed')}}:</label>
        <el-input v-model="params.n2"
                  :step="100"
                  type = "number"
                  @change="changeP"/>
        <label class="el-form-item__label">r/min</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.elasticSlipCoefficient')}}:</label>
        <el-input v-model="params.elasticSlipCoefficient"
                  :step="0.001"
                  :min="0.01"
                  :max="0.02"
                  type = "number"
                  @change ="changeElasticSlipCoefficient"/>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.workingCondition')}}:</label>
        <el-select v-model="params.workingCondition">
          <el-option
                  v-for="item in optionWorkingCondition"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.workingMode')}}:</label>
        <el-select v-model="params.workingMode">
          <el-option
                  v-for="item in optionWorkingMode"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.workingLength')}}:</label>
        <el-select v-model="params.workingLength">
          <el-option
                  v-for="item in optionWorkingLength"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
        <label class="el-form-item__label">h</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.normalTensionStressOfBelt')}}:</label>
        <el-select v-model="params.normalTensionStressOfBelt">
          <el-option
                  v-for="item in optionNormalTensionStressOfBelt"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
        <label class="el-form-item__label">N/mm²</label>
      </div>
<!--      <div class="d-flex align-items-center">-->
<!--        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltThickness')}}:</label>-->
<!--        <el-input v-model="params.beltThickness"-->
<!--                  type = "number"-->
<!--                  disabled="true"/>-->
<!--        <label class="el-form-item__label">mm</label>-->
<!--      </div>-->
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltCount')}}:</label>
        <el-input v-model="params.beltCount"
                  :step="1"
                  :min="1"
                  type = "number"
                  @change ="changeBeltCount"/>
        <label class="el-form-item__label"></label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.initCenterDistance') + '(' + parseFloat(1.5 * (params.diameter1 + params.diameter2)).toFixed(0) + '~' + parseFloat(5 * (params.diameter1 + params.diameter2)).toFixed(0) + ')'}}:</label>
        <el-input v-model="params.initCenterDistance"
                  :min="parseFloat(1.5 * (params.diameter1 + params.diameter2)).toFixed(0)"
                  :max="parseFloat(5 * (params.diameter1 + params.diameter2)).toFixed(0)"
                  type = "number"
                  @change="changeInitCenterDistance"/>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.wheelType1')}}:</label>
        <el-select v-model="params.optionWheelType1" @change="changeOptionWheelType1">
          <el-option
                  v-for="item in optionWheelType1"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.wheelType2')}}:</label>
        <el-select v-model="params.optionWheelType2" @change="changeOptionWheelType2">
          <el-option
                  v-for="item in optionWheelType2"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
      </div>
    </template>
    <template>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.wheelD1')}}:</label>
        <el-select v-model="params.paramsWheel1.D" @change="changeSolidWheelD1">
          <el-option
                  v-for="item in optionSolidWheelD1"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
    </template>
    <template>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.wheelD2')}}:</label>
        <el-select v-model="params.paramsWheel2.D" @change="changeSolidWheelD2">
          <el-option
                  v-for="item in optionSolidWheelD2"
                  :key="item"
                  :label="item"
                  :value="item">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
    </template>
    <template class="d-flex align-items-center">
      <p><b>{{ $t('message.BeltDriveTool.result') }}</b></p>
    </template>
    <template>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.drivingWheelDiameter')}}:</label>
        <el-select v-model="params.diameter1" disabled="true" @change="">
          <el-option
                  v-for="item in classParamsDrivingWheelDiameter"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.drivenWheelDiameter')}}:</label>
        <el-select v-model="params.diameter2" disabled="true" @change="">
          <el-option
                  v-for="item in classParamsDrivingWheelDiameter"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltWidth')}}:</label>
        <el-select v-model="params.beltWidth" disabled="true" @change="changeBeltWidth">
          <el-option
                  v-for="item in classParamsBeltWidth"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.wheelWidth')}}:</label>
        <el-select v-model="params.wheelWidth" disabled="true" @change="changeWheelWidth">
          <el-option
                  v-for="item in classParamsWheelWidth"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value"
                  :aria-disabled="true">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltLength')}}:</label>
        <el-select v-model="params.beltLength" disabled="true" @change="">
          <el-option
                  v-for="item in classParamsBeltLength"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value">
          </el-option>
        </el-select>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltThickness')}}:</label>
        <el-input v-model="params.beltThickness"
                  type = "number"
                  disabled="true"/>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.distance')}}:</label>
        <el-input v-model="params.distance"
                  type = "number"
                  disabled="true"/>
        <label class="el-form-item__label">mm</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.beltVelocity')}}:</label>
        <el-input v-model="params.v"
                  type = "number"
                  disabled="true"/>
        <label class="el-form-item__label">m/s</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.angle')}}:</label>
        <el-input v-model="params.angle"
                  type = "number"
                  disabled="true"/>
        <label class="el-form-item__label">°</label>
      </div>
      <div class="d-flex align-items-center">
        <label class="el-form-item__label">{{$t('message.BeltDriveTool.transmissionRatio')}}:</label>
        <el-input v-model="params.i"
                  type = "number"
                  disabled="true"/>
        <label class="el-form-item__label"></label>
      </div>
    </template>
    <div class="btn">
      <el-button
              type="primary"
              size="small"
              :disabled="isCreateModelByI || isCreateModelByV || isCreateModelByWheelType1 || isCreateModelByWheelType2 || isCreateModelByF1 || isCreateModelByF2"
              @click="createModel">
        {{ $t('message.BeltDriveTool.confirm') }}
      </el-button>
      <el-button
              size="small"
              @click="close">
        {{ $t('message.BeltDriveTool.cancel') }}
      </el-button>
    </div>
  </div>
</template>

<script>
import {beltDriveCommand} from "../../../Command/BeltDriveDesign/BeltDriveCommand";

export default {
  name: "CmdDlgFlatBeltDriveDesignTool",
  data() {
    return {
      params: {
        beltType: 'FLAT',
        loading: false,
        drivingWheelDiameterCoefficient: 1200,
        P: 3,
        n1: 2000,
        n2: 1200,
        elasticSlipCoefficient: 0.01,
        workingCondition:  this.$t('message.BeltDriveTool.minLoad'),
        workingMode: this.$t('message.BeltDriveTool.lightStart'),
        workingLength: '<10',
        normalTensionStressOfBelt: 1.6,
        beltCount: 1,
        initCenterDistance: 1200,
        wheelType: this.$t('message.BeltDriveTool.solidWheelType'),
        wheelWidth: 90,
        diameter1: 0,
        diameter2: 0,
        optionWheelType1: this.$t('message.BeltDriveTool.solidWheelType'),
        optionWheelType2: this.$t('message.BeltDriveTool.solidWheelType'),
        wheelType1: 'solidWheelType',
        wheelType2: 'solidWheelType',
        distance: 0,
        beltWidth: 80,
        beltLength: 0,
        beltThickness: 1.2,
        singleBeltThickness: 1.2,
        angle: 0,
        v: 0,
        i: 0,
        paramsWheel1: {
          d: 160,
          h: 0.5,
          D: 55,
          D1: 100,
          B: 150,
          L: 125,
          delta: 3,
          l: 50,
          S: 18,
        },
        paramsWheel2: {
          d: 500,
          h: 0.5,
          D: 95,
          D1: 190,
          B: 125,
          L: 150,
          delta: 3,
          l: 50,
          S: 18
        },
        DList1: [],
        DList2: [],
      },
      isCreateModelByI: false,
      isCreateModelByWheelType1: false,
      isCreateModelByWheelType2: false,
      isCreateModelByV: false,
      isCreateModelByF1: false,
      isCreateModelByF2: false,
      //工况
      optionWorkingCondition: [
        this.$t('message.BeltDriveTool.minLoad'),
        this.$t('message.BeltDriveTool.smallLoad'),
        this.$t('message.BeltDriveTool.bigLoad'),
        this.$t('message.BeltDriveTool.biggerLoad'),
      ],
      //启动方式
      optionWorkingMode: [
        this.$t('message.BeltDriveTool.lightStart'),
        this.$t('message.BeltDriveTool.weightStart')
      ],
      //工作时长
      optionWorkingLength: [
        '<10',
        '10~16',
        '>16'
      ],
      //带的正常张紧应力
      optionNormalTensionStressOfBelt: [
        1.6, 1.8, 2.0
      ],
      //带轮类型
      optionWheelType1: [
        //this.$t('message.BeltDriveTool.normalWheelType'),
        this.$t('message.BeltDriveTool.solidWheelType'),
        this.$t('message.BeltDriveTool.spokeWheelType'),
        this.$t('message.BeltDriveTool.fourHoleWheelType'),
        this.$t('message.BeltDriveTool.sixHoleWheelType'),
        this.$t('message.BeltDriveTool.fourOvalSpokeWheelType'),
        this.$t('message.BeltDriveTool.sixOvalSpokeWheelType')
      ],
      optionWheelType2: [
        //this.$t('message.BeltDriveTool.normalWheelType'),
        this.$t('message.BeltDriveTool.solidWheelType'),
        this.$t('message.BeltDriveTool.spokeWheelType'),
        this.$t('message.BeltDriveTool.fourHoleWheelType'),
        this.$t('message.BeltDriveTool.sixHoleWheelType'),
        this.$t('message.BeltDriveTool.fourOvalSpokeWheelType'),
        this.$t('message.BeltDriveTool.sixOvalSpokeWheelType')
      ],
      //带轮类型
      wheelTypeList1: [
        //'normalWheelType',
        'solidWheelType',
        'spokeWheelType',
        'fourHoleWheelType',
        'sixHoleWheelType',
        'fourOvalSpokeWheelType',
        'sixOvalSpokeWheelType'
      ],
      wheelTypeList2: [
        'solidWheelType',
        'spokeWheelType',
        'fourHoleWheelType',
        'sixHoleWheelType',
        'fourOvalSpokeWheelType',
        'sixOvalSpokeWheelType'
      ],
      // 带宽值列表
      classParamsBeltWidth: [
        {text:"16", value: 16},
        {text:"20", value: 20},
        {text:"25", value: 25},
        {text:"32", value: 32},
        {text:"40", value: 40},
        {text:"50", value: 50},
        {text:"63", value: 63},
        {text:"71", value: 71},
        {text:"80", value: 80},
        {text:"90", value: 90},
        {text:"100", value: 100},
        {text:"112", value: 112},
        {text:"125", value: 125},
        {text:"140", value: 140},
        {text:"160", value: 160},
        {text:"180", value: 180},
        {text:"200", value: 200},
        {text:"224", value: 224},
        {text:"250", value: 250},
        {text:"280", value: 280},
        {text:"315", value: 315},
        {text:"355", value: 355},
        {text:"400", value: 400},
        {text:"450", value: 450},
        {text:"500", value: 500},
      ],
      // 带长度值列表 /*优选系列*/
      classParamsBeltLength: [
        {text:"500", value: 500},
        {text:"560", value: 560},
        {text:"630", value: 630},
        {text:"710", value: 710},
        {text:"800", value: 800},
        {text:"900", value: 900},
        {text:"1000", value: 1000},
        {text:"1120", value: 1120},
        {text:"1250", value: 1250},
        {text:"1400", value: 1400},
        {text:"1600", value: 1600},
        {text:"1800", value: 1800},
        {text:"2000", value: 2000},
        {text:"2240", value: 2240},
        {text:"2500", value: 2500},
        {text:"2800", value: 2800},
        {text:"3150", value: 3150},
        {text:"3550", value: 3550},
        {text:"4000", value: 4000},
        {text:"4500", value: 4500},
        {text:"5000", value: 5000},
      ],
      // 轮宽值列表
      classParamsWheelWidth: [
        {text:"20", value: 20},
        {text:"25", value: 25},
        {text:"32", value: 32},
        {text:"40", value: 40},
        {text:"50", value: 50},
        {text:"63", value: 63},
        {text:"71", value: 71},
        {text:"80", value: 80},
        {text:"90", value: 90},
        {text:"100", value: 100},
        {text:"112", value: 112},
        {text:"125", value: 125},
        {text:"140", value: 140},
        {text:"160", value: 160},
        {text:"180", value: 180},
        {text:"200", value: 200},
        {text:"224", value: 224},
        {text:"250", value: 250},
        {text:"280", value: 280},
        {text:"315", value: 315},
        {text:"355", value: 355},
        {text:"400", value: 400},
        {text:"450", value: 450},
        {text:"500", value: 500},
        {text:"560", value: 560},
      ],
      // 轮直径值列表
      classParamsDrivingWheelDiameter: [
        {text:"20", value: 20},
        {text:"25", value: 25},
        {text:"32", value: 32},
        {text:"40", value: 40},
        {text:"50", value: 50},
        {text:"56", value: 56},
        {text:"63", value: 63},
        {text:"71", value: 71},
        {text:"80", value: 80},
        {text:"90", value: 90},
        {text:"100", value: 100},
        {text:"112", value: 112},
        {text:"125", value: 125},
        {text:"140", value: 140},
        {text:"160", value: 160},
        {text:"180", value: 180},
        {text:"200", value: 200},
        {text:"224", value: 224},
        {text:"250", value: 250},
        {text:"280", value: 280},
        {text:"315", value: 315},
        {text:"355", value: 355},
        {text:"400", value: 400},
        {text:"450", value: 450},
        {text:"500", value: 500},
        {text:"560", value: 560},
        {text:"630", value: 630},
        {text:"710", value: 710},
        {text:"800", value: 800},
        {text:"900", value: 900},
        {text:"1000", value: 1000},
        {text:"1120", value: 1120},
        {text:"1250", value: 1250},
        {text:"1400", value: 1400},
        {text:"1600", value: 1600},
        {text:"1800", value: 1800},
        {text:"2000", value: 2000},
      ],
      //轮冠高度
      classParamsWheelH: [
        [[20, 112], 0.3],
        [[125, 140], 0.4],
        [[160, 180], 0.5],
        [[200, 224], 0.6],
        [[250, 280], 0.8],
        [[315, 500], 1.0],
        [[560, 1000], 1.2],
        [[1120, 1400], 1.5],
        [[1600, 2000], 1.8],
      ],
      //带轮孔径数组
      optionSolidWheelD1: [
        12, 14, 16, 18
      ],
      optionSolidWheelD2: [
        12, 14, 16, 18
      ],
      //实心轮孔径
      classParamsSolidWheelD: [
        //{key:50, value:{key:[20, 32], value:[12, 14]}},
        //[d,[B],[D]]
        [50, [20, 32], [12, 14, 16, 18]],
        [50, [33, 50], [16, 18]],
        [56, [20, 32], [12, 14, 16, 18]],
        [56, [33, 50], [16, 18]],
        [63, [20, 32], [12, 14, 16, 18]],
        [63, [33, 50], [16, 18, 20, 22]],
        [63, [51, 56], [20, 22]],
        [71, [20, 32], [12, 14, 16, 18, 20, 22]],
        [71, [33, 39], [16, 18, 20, 22]],
        [71, [40, 50], [16, 18, 20, 22, 24, 25]],
        [71, [51, 56], [20, 22, 24, 25]],
        [71, [57, 80], [24, 25]],
        [80, [20, 39], [16, 18, 20, 22]],
        [80, [40, 50], [16, 18, 20, 22, 24, 25, 28, 30]],
        [80, [51, 56], [20, 22, 24, 25, 28, 30]],
        [80, [57, 80], [24, 25, 28, 30]],
        [90, [20, 39], [20, 22]],
        [90, [40, 56], [20, 22, 24, 25, 28, 30, 32, 35]],
        [90, [57, 80], [24, 25, 28, 30, 32, 35]],
        [90, [81, 125], [32, 35]],
        [100, [40, 59], [24, 25, 28, 30, 32, 35]],
        [100, [60, 80], [24, 25, 28, 30, 32, 35, 38, 40]],
        [100, [81, 125], [32, 35, 38, 40]],
        [100, [126, 160], [38, 40]],
        [112, [40, 59], [28, 30, 32, 35]],
        [112, [60, 80], [28, 30, 32, 35, 38, 40, 42, 45]],
        [112, [81, 125], [32, 35, 38, 40, 42, 45]],
        [112, [126, 160], [38, 40, 42, 45]],
        [125, [60, 89], [38, 40, 42, 45]],
        [125, [90, 160], [38, 40, 42, 45, 50, 55]],
        [125, [161, 200], [50, 55]],
        [140, [60, 89], [42, 45]],
        [140, [90, 160], [42, 45, 50, 55]],
        [140, [161, 200], [50, 55]],
        [160, [90, 200], [50, 55, 60, 65]],
        [180, [90, 200], [60, 65, 70, 75]],
        [200, [90, 149], [70, 75]],
        [200, [150, 200], [70, 75, 80, 85]],
        [200, [201, 250], [80, 85]],
        [224, [150, 250], [80, 85, 90, 95]],
        [250, [150, 250], [90, 95]],
      ],
      //辐板轮孔径
      classParamsSpokeWheelD: [
        //[d,[B],[[D]],[S]]
        [80, [20, 32], [[12, 14]], [8]],
        [90, [20, 32], [[12, 14], [16, 18]], [8, 10]],
        [90, [33, 50], [[16, 18]], 10],
        [100, [20, 32], [[12, 14], [16, 18, 20, 22]], [9, 10]],
        [100, [33, 56], [[16, 18, 20, 22]], [10]],
        [112, [20, 32], [[12, 14], [16, 18, 20, 22]], [9, 12]],
        [112, [33, 39], [[16, 18, 20, 22]], [12]],
        [112, [40, 50], [[16, 18, 20, 22, 24, 25]], [12]],
        [112, [51, 56], [[20, 22, 24, 25]], [12]],
        [112, [57, 80], [[24, 25]], [12]],
        [125, [20, 32], [[12, 14], [16, 18, 20, 22]], [10, 12]],
        [125, [33, 39], [[16, 18, 20, 22]], [12]],
        [125, [40, 50], [[16, 18, 20, 22, 24, 25, 28, 30], [32, 35]], [12, 14]],
        [125, [51, 56], [[20, 22, 24, 25, 28, 30], [32, 35]], [12, 14]],
        [125, [57, 80], [[24, 25, 28, 30], [32, 35]], [12, 14]],
        [125, [81, 125], [[32, 35]], [14]],
        [140, [20, 39], [[20, 22]], [12]],
        [140, [40, 56], [[20, 22], [24, 25, 28, 30, 32, 35]], [12, 14]],
        [140, [57, 59], [[24, 25, 28, 30, 32, 35]], [14]],
        [140, [60, 80], [[24, 25, 28, 30, 32, 35], [38, 40]], [14, 18]],
        [140, [81, 125], [[32, 35], [38, 40]], [14, 18]],
        [140, [126, 160], [[38, 40]], [18]],
        [160, [40, 59], [[32, 35]], [16]],
        [160, [60, 125], [[32, 35], [38, 40, 42, 45]], [16, 18]],
        [160, [126, 160], [[38, 40, 42, 45]], [18]],
        [180, [40, 59], [[32, 35]], [16]],
        [180, [60, 89], [[32, 35], [38, 40, 42, 45]], [16, 18]],
        [180, [90, 125], [[32, 35], [38, 40, 42, 45], [50, 55]], [16, 18, 20]],
        [180, [126, 160], [[38, 40, 42, 45], [50, 55]], [18, 20]],
        [180, [161, 200], [[50, 55]], [20]],
        [200, [60, 89], [[42, 45]], [18]],
        [200, [90, 160], [[42, 45], [50, 55, 60, 65]], [18, 20]],
        [200, [161, 200], [[50, 55, 60, 65]], [20]],
        [224, [90, 200], [[50, 55, 60, 65, 70, 75]], [20]],
        [250, [90, 149], [[60, 65, 70, 75]], [20]],
        [250, [150, 200], [[60, 65, 70, 75], [80, 85]], [20, 22]],
        [250, [201, 250], [[80, 85]], [22]],
        [280, [90, 149], [[70, 75]], [22]],
        [280, [150, 200], [[70, 75, 80, 85], [90, 95]], [22, 24]],
        [280, [201, 250], [[80, 85], [90, 95]], [22, 24]],
        [315, [150, 250], [[80, 85, 90, 95]], [24]],
        [355, [150, 250], [[90, 95]], [24]],
      ],
      //四孔板轮孔径
      classParamsFourHoleWheelTypeD: [
        //[d,[B],[[D]],[S]]
        [140, [20, 32], [[12, 14], [16, 18]], [10, 12]],
        [140, [23, 50], [[16, 18]], [12]],
        [160, [20, 32], [[12, 14], [16, 18, 20, 22]], [10, 12]],
        [160, [33, 39], [[16, 18, 20, 22]], [12]],
        [160, [40, 50], [[16, 18, 20, 22], [24, 25, 28, 30]], [12, 14]],
        [160, [51, 56], [[20, 22], [24, 25, 28, 30]], [12, 14]],
        [160, [57, 80], [[24, 25, 28, 30]], [14]],
        [180, [20, 32], [[12, 14], [16, 18, 20, 22]], [10, 12]],
        [180, [33, 39], [[16, 18, 20, 22]], [12]],
        [180, [40, 50], [[16, 18, 20, 22], [24, 25, 28, 30]], [12, 14]],
        [180, [51, 56], [[20, 22], [24, 25, 28, 30]], [12, 14]],
        [180, [57, 80], [[24, 25, 28, 30]], [14]],
        [200, [20, 39], [[16, 18, 20, 22]], [14]],
        [200, [40, 50], [[16, 18, 20, 22, 24, 25, 28, 30], [32, 35]], [14, 16]],
        [200, [51, 56], [[20, 22, 24, 25, 28, 30], [32, 35]], [14, 16]],
        [200, [57, 80], [[24, 25, 28, 30], [32, 35]], [14, 16]],
        [200, [81, 125], [[32, 35]], [16]],
        [224, [20, 39], [[16, 18, 20, 22]], [14]],
        [224, [40, 50], [[16, 18, 20, 22], [24, 25, 28, 30], [32, 35]], [14, 16, 18]],
        [224, [51, 56], [[20, 22], [24, 25, 28, 30], [32, 35]], [14, 16, 18]],
        [224, [57, 80], [[24, 25, 28, 30], [32, 35]], [16, 18]],
        [224, [81, 125], [[32, 35]], [18]],
        [250, [20, 39], [[20, 22]], [14]],
        [250, [40, 56], [[20, 22], [24, 25, 28, 30], [32, 35]], [14, 16, 18]],
        [250, [57, 59], [[24, 25, 28, 30]], [16]],
        [250, [60, 80], [[24, 25, 28, 30], [32, 35], [38, 40]], [16, 18, 20]],
        [250, [81, 125], [[32, 35], [38, 40]], [18, 20]],
        [250, [126, 160], [[38, 40]], [120]],
        [280, [20, 39], [[20, 22]], [14]],
        [280, [40, 56], [[20, 22], [24, 25, 28, 30], [32, 35]], [14, 16, 18]],
        [280, [57, 59], [[24, 25, 28, 30]], [16]],
        [280, [60, 80], [[24, 25, 28, 30], [32, 35], [38, 40]], [16, 18, 20]],
        [280, [81, 125], [[32, 35], [38, 40]], [18, 20]],
        [280, [126, 160], [[38, 40]], [20]],
        [315, [40, 59], [[28, 30], [32, 35]], [18, 20]],
        [315, [60, 80], [[28, 30], [32, 35], [38, 40, 42, 45]], [18, 20, 22]],
        [315, [81, 125], [[32, 35], [38, 40, 42, 45]], [20, 22]],
        [315, [126, 160], [[38, 40, 42, 45]], [22]],
        [355, [40, 59], [[28, 30], [32, 35]], [20, 22]],
        [355, [60, 80], [[28, 30], [32, 35, 38, 40], [42, 45]], [20, 22, 24]],
        [355, [81, 89], [[32, 35, 38, 40], [42, 45]], [22, 24]],
        [355, [90, 125], [[32, 35, 38, 40], [42, 45, 50, 55]], [22, 24]],
        [355, [126, 160], [[38, 40], [42, 45, 50, 55]], [22, 24]],
        [355, [161, 200], [[50, 55]], [22, 24]],
        [400, [81, 89], [[42, 45]], [24]],
        [400, [90, 160], [[42, 45, 50, 55, 60, 65]], [24]],
        [400, [161, 200], [[50, 55, 60, 65]], [24]],
        [450, [90, 200], [[60, 65]], [26]],
      ],
      //六孔板轮孔径
      classParamsSixHoleWheelTypeD: [
        //[d,[B],[[D]],[S]]
        [200, [60, 160], [[38, 40]], [18]],
        [224, [60, 160], [[38, 40, 42, 45]], [20]],
        [250, [60, 89], [[42, 45]], [20]],
        [250, [90, 160], [[42, 45, 50, 55]], [20]],
        [250, [161, 200], [[50, 55]], [20]],
        [280, [60, 89], [[42, 45]], [20]],
        [280, [90, 160], [[42, 45], [50, 55, 60, 65]], [20, 22]],
        [280, [161, 200], [[50, 55, 60, 65]], [22]],
        [315, [90, 200], [[50, 55, 60, 65, 70, 75]], [24]],
        [355, [90, 149], [[60, 65, 70, 75]], [24]],
        [355, [150, 200], [[60, 65, 70, 75, 80, 85]], [24]],
        [355, [201, 250], [[80, 85]], [24]],
        [400, [90, 149], [[70, 75]], [24]],
        [400, [150, 200], [[70, 75, 80, 85], [90, 95]], [24, 26]],
        [400, [201, 250], [[90, 95]], [26]],
        [450, [90, 149], [[70, 75]], [24]],
        [450, [150, 200], [[70, 75, 80, 85, 90, 95]], [26]],
        [450, [201, 250], [[90, 95]], [26]],
      ],
      //四椭圆辐轮孔径
      classParamsFourOvalSpokeWheelTypeD: [
        //[d,[B],[D]]
        [400, [40, 59], [32, 35]],
        [400, [60, 125], [32, 35, 38, 40]],
        [400, [126, 160], [38, 40]],
        [450, [40, 59], [32, 35]],
        [450, [60, 89], [32, 35, 38, 40, 42, 45]],
        [450, [90, 125], [32, 35, 38, 40, 42, 45, 50, 55]],
        [450, [126, 160], [38, 40, 42, 45, 50, 55]],
        [450, [161, 200], [50, 55]],
        [500, [40, 59], [32, 35]],
        [500, [60, 89], [32, 35, 38, 40, 42, 45]],
        [500, [90, 125], [32, 35, 38, 40, 42, 45, 50, 55, 60, 65]],
        [500, [126, 160], [38, 40, 42, 45, 50, 55, 60, 65]],
        [500, [161, 200], [50, 55, 60, 65]],
      ],
      //六椭圆辐轮孔径
      classParamsSixOvalSpokeWheelTypeD: [
        //[[d],[B],[D]]
        [[500, 500], [90, 149], [70, 75]],
        [[500, 500], [150, 200], [70, 75, 80, 85, 90, 95]],
        [[500, 500], [201, 250], [80, 85, 90, 95]],

        [[560, 2000], [40, 59], [32, 35]],
        [[560, 2000], [60, 89], [32, 35, 38, 40, 42, 45]],
        [[560, 2000], [90, 125], [32, 35, 38, 40, 42, 45, 50, 55, 60, 65, 70, 75]],
        [[560, 2000], [126, 149], [38, 40, 42, 45, 50, 55, 60, 65, 70, 75]],
        [[560, 2000], [150, 160], [38, 40, 42, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]],
        [[560, 2000], [161, 200], [50, 55, 60, 65, 70, 75, 80, 85, 90, 95]],
        [[560, 2000], [201, 250], [80, 85, 90, 95]],
      ],
      //工况系数KA
      classParamsWorkingConditionFactor: [
        [
          [
            1.0, 1.1, 1.2
          ],
          [
            1.1, 1.2, 1.3
          ],
        ],
        [
          [
            1.1, 1.2, 1.3
          ],
          [
            1.2, 1.3, 1.4
          ],
        ],
        [
          [
            1.2, 1.3, 1.4
          ],
          [
            1.4, 1.5, 1.6
          ],
        ],
        [
          [
            1.3, 1.4, 1.5
          ],
          [
            1.5, 1.6, 1.8
          ],
        ],
      ],
      // 包角修正系数
      classParamsAngleCorrectionFactor: [
        {key:"120", value: 0.82},
        {key:"130", value: 0.85},
        {key:"140", value: 0.88},
        {key:"150", value: 0.91},
        {key:"160", value: 0.94},
        {key:"170", value: 0.97},
        {key:"180", value: 1.00},
        {key:"190", value: 1.05},
        {key:"200", value: 1.10},
        {key:"210", value: 1.15},
        {key:"220", value: 1.20},
      ],
      //直径与厚度之比
      classParamsDiameterBeltThicknessRatio: [
        30, 35, 40, 45, 50, 60, 75, 100
      ],
      classParamsV: [
        5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
      ],
      //单位截面积传递的额定功率
      classParamsRatedPower: [
        /*30*/[1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.0, 3.2, 3.3, 3.5, 3.6, 3.7, 3.8, 4.0, 4.0, 4.1, 4.2, 4.3, 4.3, 4.3, 4.3, 4.3],
        /*35*/[1.1, 1.3, 1.5, 1.7, 2.0, 2.2, 2.4, 2.5, 2.7, 2.9, 3.1, 3.2, 3.4, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.1, 4.3, 4.3, 4.4, 4.4, 4.4, 4.4],
        /*40*/[1.1, 1.3, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 2.9, 3.1, 3.3, 3.4, 3.6, 3.7, 3.9, 4.0, 4.1, 4.2, 4.3, 4.3, 4.4, 4.4, 4.4, 4.5, 4.5],
        /*45*/[1.1, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 2.9, 3.1, 3.3, 3.4, 3.6, 3.7, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.5, 4.5, 4.5, 4.6],
        /*50*/[1.2, 1.4, 1.6, 1.8, 2.1, 2.3, 2.5, 2.6, 2.8, 3.0, 3.2, 3.4, 3.5, 3.7, 3.8, 4.0, 4.0, 4.2, 4.3, 4.4, 4.4, 4.5, 4.5, 4.5, 4.6, 4.6],
        /*60*/[1.2, 1.4, 1.6, 1.8, 2.1, 2.3, 2.5, 2.7, 2.9, 3.1, 3.3, 3.4, 3.6, 3.7, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.6, 4.6, 4.6, 4.7],
        /*75*/[1.2, 1.4, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.1, 3.3, 3.5, 3.6, 3.8, 3.9, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.6, 4.7, 4.7, 4.7, 4.7],
        /*75*/[1.2, 1.4, 1.7, 1.9, 2.1, 2.4, 2.6, 2.8, 2.9, 3.2, 3.4, 3.5, 3.7, 3.9, 4.0, 4.1, 4.2, 4.4, 4.5, 4.6, 4.6, 4.7, 4.7, 4.7, 4.8, 4.8],
      ]

    }
  },

  mounted() {
    this.loaded = true;
    this.initBasicParams();
    this.calculateAllParams();
  },

  methods: {
    subscribeElementPick () {
      beltDriveCommand.handlePickElement((object) => {
      });
    },
    createModel() {
      const loading = this.$loading({
        lock: true,
        text: this.$t('message.BeltDriveTool.loading'),
        spinner: "el-icon-loading"
      });
      beltDriveCommand.createFlatBeltDrive(this.params, () => {
        // 进度结束
        loading.close();
      });
    },
    changeP() {
      this.changePParam();
      this.initBasicParams();
      this.calculateAllParams();
      this.judgeWheelType();
    },
	  changePParam() {
      if(parseFloat(this.params.P) < 0) {
        this.params.P = 1;
      }
	  },
    judgeWheelType() {
      if(this.params.wheelType1 === "") {
        let msg ='当前规格无法找到对应带轮类型';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByWheelType1 = true;
      } else {
        this.isCreateModelByWheelType1 = false;
      }
      if(this.params.wheelType2 === "") {
        let msg ='当前规格无法找到对应带轮类型';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByWheelType2 = true;
      } else {
        this.isCreateModelByWheelType2 = false;
      }
      if(this.params.wheelType1 === 'fourOvalSpokeWheelType' || this.params.wheelType1 === 'sixOvalSpokeWheelType') {
        this.changeParamsWheelD1();
      }
      if(this.params.wheelType2 === 'fourOvalSpokeWheelType' || this.params.wheelType2 === 'sixOvalSpokeWheelType') {
        this.changeParamsWheelD2();
      }
    },
    changeBeltWidth(value) {
      let index = this.classParamsBeltWidth.findIndex(item => item.value === value);
      console.log("index:" + index);
      if(index !== -1) {
        this.params.wheelWidth = this.classParamsWheelWidth[index].value;
      }
    },
    changeWheelWidth(value) {
      let index = this.classParamsWheelWidth.findIndex(item => item.value === value);
      console.log("index:" + index);
      if(index !== -1) {
        this.params.beltWidth = this.classParamsBeltWidth[index].value;
      }
    },
    changeDrivingWheelDiameterCoefficient() {
      if(parseFloat(this.params.drivingWheelDiameterCoefficient) > 1300) {
        this.params.drivingWheelDiameterCoefficient = 1300;
      } else if(parseFloat(this.params.drivingWheelDiameterCoefficient) < 1100) {
        this.params.drivingWheelDiameterCoefficient = 1100;
      } else{
        this.params.drivingWheelDiameterCoefficient = this.params.drivingWheelDiameterCoefficient;
      }
    },
    changeElasticSlipCoefficient() {
      if(parseFloat(this.params.elasticSlipCoefficient) > 0.02) {
        this.params.elasticSlipCoefficient = 0.02;
      } else if(parseFloat(this.params.elasticSlipCoefficient) < 0.01) {
        this.params.elasticSlipCoefficient = 0.01;
      } else{
        this.params.elasticSlipCoefficient = this.params.elasticSlipCoefficient;
      }
    },
    changeBeltCount() {
      if(parseFloat(this.params.beltCount) < 1) {
        this.params.beltCount = 1;
      } else{
        let beltCount = parseFloat(this.params.beltCount);
        this.params.beltCount = Math.round(beltCount);
      }
    },
    changeOptionWheelType1(value) {
      let index = this.optionWheelType1.findIndex(item => item === value);
      console.log("index:" + index);
      if(index !== -1) {
        this.params.wheelType1 = this.wheelTypeList1[index];
      }
    },
    changeOptionWheelType2(value) {
      let index = this.optionWheelType2.findIndex(item => item === value);
      console.log("index:" + index);
      if(index !== -1) {
        this.params.wheelType2 = this.wheelTypeList2[index];
      }
    },
    changeInitCenterDistance() {
      if(parseFloat(this.params.initCenterDistance) > 5 * (this.params.diameter1 + this.params.diameter2) ) {
        this.params.initCenterDistance = parseFloat(5 * (this.params.diameter1 + this.params.diameter2)).toFixed(3);
      } else if(parseFloat(this.params.initCenterDistance) < 1.5 * (this.params.diameter1 + this.params.diameter2)) {
        this.params.initCenterDistance = parseFloat(1.5 * (this.params.diameter1 + this.params.diameter2)).toFixed(3);
      } else{
        this.params.initCenterDistance = parseFloat(this.params.initCenterDistance).toFixed(3);
      }
    },
    initBasicParams() {
      //异常处理
      if(parseFloat(this.params.drivingWheelDiameterCoefficient) < 1100 || parseFloat(this.params.drivingWheelDiameterCoefficient) > 1300 || this.params.drivingWheelDiameterCoefficient === "") {
        return;
      }
      if(parseFloat(this.params.n1) === 0 || this.params.n1 === "" || parseFloat(this.params.n2) === 0 || this.params.n2 === "") {
        return;
      }
      if(parseFloat(this.params.elasticSlipCoefficient) < 0.01 || parseFloat(this.params.elasticSlipCoefficient) > 0.02 || this.params.elasticSlipCoefficient === "") {
        return;
      }

      //转速比
      this.params.i = parseFloat(parseFloat(this.params.n1 / this.params.n2).toFixed(3));
      if(this.params.i < 1) {
        let msg ='传动比不能小于1，请重新输入转速';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByI = true;
        return;
      }else if(this.params.i > 5) {
        let msg ='传动比不能大于5，请重新输入转速';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByI = true;
        return;
      } else {
        this.isCreateModelByI = false;
      }
      //小带轮
      let diameter1 = this.params.drivingWheelDiameterCoefficient * Math.cbrt(this.params.P / this.params.n1);
      this.params.diameter1 = this.findValueByValue(this.classParamsDrivingWheelDiameter, diameter1);
      //大带轮
      let diameter2 = this.params.i * this.params.diameter1 * (1 - this.params.elasticSlipCoefficient);
      this.params.diameter2 = this.findValueByValue(this.classParamsDrivingWheelDiameter, diameter2);
      //初定中心距
      this.params.initCenterDistance = parseFloat(1.6 * (this.params.diameter1 + this.params.diameter2)).toFixed(3);
    },
    calculateAllParams() {
      if(this.params.initCenterDistance < 1.5 * (this.params.diameter1 + this.params.diameter2) || this.params.initCenterDistance > 5 * (this.params.diameter1 + this.params.diameter2)) {
        return;
      }
      if(parseFloat(this.params.beltCount) === 0 || this.params.beltCount === "") {
        return;
      }
      //带厚
      this.params.beltThickness = parseFloat(1.2 * this.params.beltCount).toFixed(3);
      //带速
      this.params.v = parseFloat(Math.PI * this.params.diameter1 * this.params.n1 / (60 * 1000)).toFixed(3);
      if(parseFloat(this.params.v) < 5) {
        let msg ='带速不能小于5，请重新输入传递功率，或主动轮转速或直径';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByV = true;
        return;
      } else if(parseFloat(this.params.v) > 30) {
        let msg ='带速不能大于30，请重新输入传递功率，或主动轮转速或直径';
        beltDriveCommand.closeAllAlert();
        beltDriveCommand.eventBusAlertMsg(msg, 'warning');
        this.isCreateModelByV = true;
        return;
      } else {
        this.isCreateModelByV = false;
      }
      //包角
      this.params.angle = parseFloat(180 - (Math.abs(this.params.diameter2 - this.params.diameter1) / this.params.initCenterDistance) * 60).toFixed(3);
      //带的节线长度
      let lineLength = parseFloat(2 * this.params.initCenterDistance + (Math.PI / 2) * (this.params.diameter1 + this.params.diameter2)
        + Math.pow((this.params.diameter2  - this.params.diameter1), 2) / (4 * this.params.initCenterDistance));
      //带的内周长度
      let inLength = parseFloat(lineLength - (Math.PI  * this.params.beltThickness));
      this.params.beltLength = this.findValueByValue(this.classParamsBeltLength, inLength);
      //带的节线修正长度
      let lineCorrectionLength = parseFloat(this.params.beltLength + (Math.PI  * this.params.beltThickness));
      //实际中心距
      this.params.distance = parseFloat(parseFloat(this.params.initCenterDistance) + (parseFloat(lineCorrectionLength) - parseFloat(lineLength)) / 2).toFixed(3);
      //带宽
      //设计功率
      let KA = 1.0;
      let indexKA1 = this.optionWorkingCondition.findIndex(item => item === this.params.workingCondition);
      let indexKA2 = this.optionWorkingMode.findIndex(item => item === this.params.workingMode);
      let indexKA3 = this.optionWorkingLength.findIndex(item => item === this.params.workingLength);
      if(indexKA1 !== -1 && indexKA2 !== -1 && indexKA3 !== -1) {
        KA = this.classParamsWorkingConditionFactor[indexKA1][indexKA2][indexKA3];
      }
      let Pd = KA * parseFloat(this.params.P);
      //包角修正系数
      let Ka = this.findValueByKey(this.classParamsAngleCorrectionFactor, this.params.angle);
      console.log('Ka: ' + Ka);
      //传动布置系数
      let Kb = 1.0;
      //平带单位截面积
      let P0 = 2.7;
      let dBRatio = this.params.diameter1 / this.params.beltThickness;
      let diameterBeltThicknessRatio = this.findValue(this.classParamsDiameterBeltThicknessRatio, dBRatio);
      let beltV = this.findValue(this.classParamsV, this.params.v);
      let indexP01 = this.classParamsDiameterBeltThicknessRatio.findIndex(item => item === diameterBeltThicknessRatio);
      let indexP02 = this.classParamsV.findIndex(item => item === beltV);
      if(this.params.normalTensionStressOfBelt === 2.0) {
        indexP02 = 5;
      }
      if(indexP01 !== -1 && indexP02 !== -1) {
        P0 = this.classParamsRatedPower[indexP01][indexP02];
      }
      if(this.params.normalTensionStressOfBelt === 1.6) {
        P0 = P0 * (1 - 0.078);
      } else if(this.params.normalTensionStressOfBelt === 1.8) {
        P0 = P0 ;
      } else if(this.params.normalTensionStressOfBelt === 2.0) {
        P0 = P0 * (1 + 0.078) * (this.params.v / 10);
      }
      let A = Pd / (Ka * Kb *P0);
      //带宽
      let b = 100 * A / this.params.beltThickness;
      this.params.beltWidth = this.findValueByValue(this.classParamsBeltWidth, b);
      this.changeBeltWidth(this.params.beltWidth);
    },

    /*直径与轮宽确定带轮类型Start*/
    initWheelTypeList(type) {
      let d = 0;
      let B = parseFloat(this.params.wheelWidth);
      if(type === 1) {
        d = parseFloat(this.params.diameter1);
      } else if(type === 2) {
        d = parseFloat(this.params.diameter2);
      }
      //带轮类型
      let curOptionWheelType = [];
      let curWheelTypeList = [];
      //实心轮
      for(let i = 0; i < this.classParamsSolidWheelD.length; i++) {
        let item = this.classParamsSolidWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.solidWheelType'));
            curWheelTypeList.push('solidWheelType');
            break;
          }
        }
      }
      //辐板轮
      for(let i = 0; i < this.classParamsSpokeWheelD.length; i++) {
        let item = this.classParamsSpokeWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.spokeWheelType'));
            curWheelTypeList.push('spokeWheelType');
            break;
          }
        }
      }
      //四孔板轮
      for(let i = 0; i < this.classParamsFourHoleWheelTypeD.length; i++) {
        let item = this.classParamsFourHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.fourHoleWheelType'));
            curWheelTypeList.push('fourHoleWheelType');
            break;
          }
        }
      }
      //六孔板轮
      for(let i = 0; i < this.classParamsSixHoleWheelTypeD.length; i++) {
        let item = this.classParamsSixHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.sixHoleWheelType'));
            curWheelTypeList.push('sixHoleWheelType');
            break;
          }
        }
      }
      //四椭圆辐轮
      for(let i = 0; i < this.classParamsFourOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsFourOvalSpokeWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.fourOvalSpokeWheelType'));
            curWheelTypeList.push('fourOvalSpokeWheelType');
            break;
          }
        }
      }
      //六椭圆辐轮
      for(let i = 0; i < this.classParamsSixOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsSixOvalSpokeWheelTypeD[i];
        if (d >= item[0][0] && d <= item[0][1]) {
          if (B >= item[1][0] && B <= item[1][1]) {
            curOptionWheelType.push(this.$t('message.BeltDriveTool.sixOvalSpokeWheelType'));
            curWheelTypeList.push('sixOvalSpokeWheelType');
            break;
          }
        }
      }
      if(type === 1) {
        this.optionWheelType1 = curOptionWheelType;
        this.wheelTypeList1 = curWheelTypeList;
        if (this.wheelTypeList1.length > 0) {
          let index = this.wheelTypeList1.findIndex(item => item === this.params.wheelType1);
          if (index === -1) {
            this.params.wheelType1 = this.wheelTypeList1[0];
            this.params.optionWheelType1 = this.optionWheelType1[0];
          }
          this.isCreateModelByWheelType1 = false;
        } else {
          this.params.wheelType1 = '';
          this.params.optionWheelType1 = '';
          this.params.paramsWheel1.D = '';
          this.optionSolidWheelD1 = [];
          let msg ='当前规格无法找到对应带轮类型';
          beltDriveCommand.closeAllAlert();
          beltDriveCommand.eventBusAlertMsg(msg, 'warning');
          this.isCreateModelByWheelType1 = true;
        }
      } else if(type === 2) {
        this.optionWheelType2 = curOptionWheelType;
        this.wheelTypeList2 = curWheelTypeList;
        if(this.wheelTypeList2.length > 0) {
          let index = this.wheelTypeList2.findIndex(item => item === this.params.wheelType2);
          if(index === -1) {
            this.params.wheelType2 = this.wheelTypeList2[0];
            this.params.optionWheelType2 = this.optionWheelType2[0];
          }
          this.isCreateModelByWheelType2 = false;
        } else {
          this.params.wheelType2 = '';
          this.params.optionWheelType2 = '';
          this.params.paramsWheel2.D = '';
          this.optionSolidWheelD2 = [];
          let msg ='当前规格无法找到对应带轮类型';
          beltDriveCommand.closeAllAlert();
          beltDriveCommand.eventBusAlertMsg(msg, 'warning');
          this.isCreateModelByWheelType2 = true;
        }
      }
      return;
    },
    /*直径与轮宽确定带轮类型End*/

    /*椭圆辐轮f1、f2判断*/
    judgeF(wheelParams, n, m, type) {
      let P = parseFloat(this.params.P);
      let d = parseFloat(wheelParams.d);
      let radian = 2 * Math.PI / m;
      let D = parseFloat(wheelParams.D);
      let D1 = parseFloat(wheelParams.D1);
      let B = parseFloat(wheelParams.B);
      let L = parseFloat(wheelParams.L);
      let delta = 0.005 * d + 3;
      let solidBotY = ((D1 - D) / 2);

      let h1 = 290 * Math.cbrt(P / (n * m));
      let h2 = 0.8 * h1;
      let a = 0.4 * h1;
      let a2 = 0.8 * a;
      let f1 = 0.2 * h1;
      let f2 = 0.2 * h2;
      let w1 = h1 / 2;
      let w2 = h2 / 2;

      let innerR = D1 / 2 + f1;
      let outerR = d / 2 - delta - f2;
      let diffR = outerR - innerR;

      //下弧
      let botPnt1x = innerR * Math.cos((Math.PI / 2) - (radian / 2));
      let offsX1 = botPnt1x - w1;
      if(m === 4) {
        offsX1 = 1;
      }

      let diffBA1 = (B - a) / 2;
      let diffBA2 = (B - a2) / 2;
      let diffLA1 = (L - a) / 2;
      let diffTop = (B - a) / 2;
      if (diffTop > solidBotY) {
        diffTop = solidBotY;
      }
      let leftX = 0.2 * solidBotY;
      let topX = 0.2 * diffTop;
      let radian1 = Math.atan(1 / 25);

      let diffSlopeBotLeftY = 0;
      let diffSlopeTopY = 0;
      let diffSlopeBotRightY = 0;

      if(L > B) {
        let slopeBotLeftY = (diffLA1 - leftX) * Math.tan(radian1);
        diffSlopeBotLeftY = f1 - slopeBotLeftY;
        diffSlopeBotRightY = diffSlopeBotLeftY;

        let slopeTopY = (diffBA2 - topX) * Math.tan(radian1);
        diffSlopeTopY = f2 - slopeTopY;
      } else if(L <= B){
        let leftL = 0.35 * L;
        let rightL = 0.65 * L;
        let rightX = 0.2 * solidBotY;
        let midBotX = 0.1 * solidBotY;

        let slopeBotLeftY = (leftL - midBotX - a/2) * Math.tan(radian1);
        diffSlopeBotLeftY = f1 - slopeBotLeftY;
        let slopeBotRightY = (rightL - rightX - a/2) * Math.tan(radian1);
        diffSlopeBotRightY = f1 - slopeBotRightY;

        let slopeTopY = (diffBA2 - topX) * Math.tan(radian1);
        diffSlopeTopY = f2 - slopeTopY;
      }
      if(diffSlopeBotLeftY <= 0 || diffSlopeTopY <= 0 || diffSlopeBotRightY <=0 || offsX1 <= 0) {
        let msg = '';
        if(type === 1) {
          if(diffSlopeBotLeftY <= 0 || diffSlopeTopY <= 0 || diffSlopeBotRightY <=0) {
            msg ='主动轮的椭圆辐轮厚度过小，请增加功率或减小主动轮转速';
          } else if(offsX1 <= 0) {
            msg ='主动轮的椭圆辐轮厚度过小，请减小功率或增加主动轮转速';
          }
          beltDriveCommand.closeAllAlert();
          beltDriveCommand.eventBusAlertMsg(msg, 'warning');
          this.isCreateModelByF1 = true;
        } else if(type === 2) {
          if(diffSlopeBotLeftY <= 0 || diffSlopeTopY <= 0 || diffSlopeBotRightY <=0) {
            msg ='从动轮的椭圆辐轮厚度过小，请增加功率或减小从动轮转速';
          } else if(offsX1 <= 0) {
            msg ='从动轮的椭圆辐轮厚度过小，请减小功率或增加从动轮转速';
          }
          beltDriveCommand.closeAllAlert();
          beltDriveCommand.eventBusAlertMsg(msg, 'warning');
          this.isCreateModelByF2 = true;
        }
      } else {
        if(type === 1) {
          this.isCreateModelByF1 = false;
        } else if(type === 2) {
          this.isCreateModelByF2 = false;
        }
      }
    },

    /*孔径与辐板厚度Start*/
    initParamsWheelD1() {
      this.initWheelTypeList(1);
      this.params.paramsWheel1.D = '';
      this.optionSolidWheelD1 = [];
      switch(this.params.wheelType1){
        case 'solidWheelType':
          this.isCreateModelByF1 = false;
          this.initSolidWheelD1();
          break;
        case 'spokeWheelType':
          this.isCreateModelByF1 = false;
          this.initSpokeWheelD1();
          break;
        case 'fourHoleWheelType':
          this.isCreateModelByF1 = false;
          this.initFourHoleWheelD1();
          break;
        case 'sixHoleWheelType':
          this.isCreateModelByF1 = false;
          this.initSixHoleWheelD1();
          break;
        case 'fourOvalSpokeWheelType':
          this.initFourOvalSpokeWheelD1();
          break;
        case 'sixOvalSpokeWheelType':
          this.initSixOvalSpokeWheelD1();
          break;
        default:
          break;
      }
    },
    initParamsWheelD2() {
      this.initWheelTypeList(2);
      this.params.paramsWheel2.D = '';
      this.optionSolidWheelD2 = [];
      switch(this.params.wheelType2){
        case 'solidWheelType':
          this.isCreateModelByF2 = false;
          this.initSolidWheelD2();
          break;
        case 'spokeWheelType':
          this.isCreateModelByF2 = false;
          this.initSpokeWheelD2();
          break;
        case 'fourHoleWheelType':
          this.isCreateModelByF2 = false;
          this.initFourHoleWheelD2();
          break;
        case 'sixHoleWheelType':
          this.isCreateModelByF2 = false;
          this.initSixHoleWheelD2();
          break;
        case 'fourOvalSpokeWheelType':
          this.initFourOvalSpokeWheelD2();
          break;
        case 'sixOvalSpokeWheelType':
          this.initSixOvalSpokeWheelD2();
          break;
        default:
          break;
      }
    },
    /*孔径改变*/
    changeParamsWheelD1() {
      switch(this.params.wheelType1) {
        case 'spokeWheelType':
        case 'fourHoleWheelType':
        case 'sixHoleWheelType':
          this.changeSpokeWheelD1();
          break;
        case 'fourOvalSpokeWheelType':
          this.judgeF(this.params.paramsWheel1, parseFloat(this.params.n1), 4, 1);
          break;
        case 'sixOvalSpokeWheelType':
          this.judgeF(this.params.paramsWheel1, parseFloat(this.params.n1), 6, 1);
          break;
        default:
          break;
      }
    },
    changeParamsWheelD2() {
      switch(this.params.wheelType2) {
        case 'spokeWheelType':
        case 'fourHoleWheelType':
        case 'sixHoleWheelType':
          this.changeSpokeWheelD2();
          break;
        case 'fourOvalSpokeWheelType':
          this.judgeF(this.params.paramsWheel2, parseFloat(this.params.n2), 4, 2);
          break;
        case 'sixOvalSpokeWheelType':
          this.judgeF(this.params.paramsWheel2, parseFloat(this.params.n2), 6, 2);
          break;
        default:
          break;
      }
    },
    /*轮冠选值*/
    getWheelH(d) {
      let h = 0.3;
      for(let index = 0; index < this.classParamsWheelH.length; index++) {
        let hList = this.classParamsWheelH[index];
        if(d >= hList[0][0] && d <= hList[0][1]) {
          h = hList[1];
          break;
        }
      }
      return h;
    },

    /*实心轮Start*/
    initSolidWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSolidWheelD.length; i++) {
        let item = this.classParamsSolidWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD1 = item[2];
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            break;
          }
        }
      }
    },
    initSolidWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSolidWheelD.length; i++) {
        let item = this.classParamsSolidWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD2 = item[2];
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            break;
          }
        }
      }
    },
    changeSolidWheelD1(value) {
      this.params.paramsWheel1.d = this.params.diameter1;
      this.params.paramsWheel1.B = this.params.wheelWidth;
      this.params.paramsWheel1.l = 0.4 * this.params.paramsWheel1.B;
      this.params.paramsWheel1.L = 2 * value;
      this.params.paramsWheel1.D1 = 1.8 * value;
      this.params.paramsWheel1.delta = 0.005 * parseFloat(this.params.paramsWheel1.d) + 3;
    },
    changeSolidWheelD2(value) {
      this.params.paramsWheel2.d = this.params.diameter2;
      this.params.paramsWheel2.B = this.params.wheelWidth;
      this.params.paramsWheel2.l = 0.4 * this.params.paramsWheel2.B;
      this.params.paramsWheel2.L = 2 * value;
      this.params.paramsWheel2.D1 = 1.8 * value;
      this.params.paramsWheel2.delta = 0.005 * parseFloat(this.params.paramsWheel2.d) + 3;
    },
    /*实心轮End*/

    /*辐板轮Start*/
    initSpokeWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSpokeWheelD.length; i++) {
        let item = this.classParamsSpokeWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD1 = list;
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.params.paramsWheel1.S = item[3][0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            this.params.DList1 = item;
            break;
          }
        }
      }
    },
    initSpokeWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSpokeWheelD.length; i++) {
        let item = this.classParamsSpokeWheelD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD2 = list;
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.params.paramsWheel2.S = item[3][0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            this.params.DList2 = item;
            break;
          }
        }
      }
    },
    changeSpokeWheelD1() {
      let item = this.params.DList1;
      let d = this.params.paramsWheel1.d;
      let B = this.params.paramsWheel1.B;
      let D = this.params.paramsWheel1.D;
      if(d === item[0] && (B >= item[1][0] && B <= item[1][1])) {
        for(let i = 0; i < item[2].length; i++) {
          let temp = item[2][i];
          for(let j = 0; j < temp.length; j++) {
            if(D === temp[j]) {
              this.params.paramsWheel1.S = item[3][i];
              break;
            }
          }
        }
      }
    },
    changeSpokeWheelD2() {
      let item = this.params.DList2;
      let d = this.params.paramsWheel2.d;
      let B = this.params.paramsWheel2.B;
      let D = this.params.paramsWheel2.D;
      if(d === item[0] && (B >= item[1][0] && B <= item[1][1])) {
        for(let i = 0; i < item[2].length; i++) {
          let temp = item[2][i];
          for(let j = 0; j < temp.length; j++) {
            if(D === temp[j]) {
              this.params.paramsWheel2.S = item[3][i];
              break;
            }
          }
        }
      }
    },
    /*辐板轮End*/

    /*四孔板轮Start*/
    initFourHoleWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsFourHoleWheelTypeD.length; i++) {
        let item = this.classParamsFourHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD1 = list;
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.params.paramsWheel1.S = item[3][0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            this.params.DList1 = item;
            break;
          }
        }
      }
    },
    initFourHoleWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsFourHoleWheelTypeD.length; i++) {
        let item = this.classParamsFourHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD2 = list;
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.params.paramsWheel2.S = item[3][0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            this.params.DList2 = item;
            break;
          }
        }
      }
    },
    /*四孔板轮End*/

    /*六孔板轮Start*/
    initSixHoleWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSixHoleWheelTypeD.length; i++) {
        let item = this.classParamsSixHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD1 = list;
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.params.paramsWheel1.S = item[3][0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            this.params.DList1 = item;
            break;
          }
        }
      }
    },
    initSixHoleWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSixHoleWheelTypeD.length; i++) {
        let item = this.classParamsSixHoleWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            let list = [];
            for(let j = 0; j < item[2].length; j++) {
              let temp = item[2][j];
              list = list.concat(temp);
            }
            this.optionSolidWheelD2 = list;
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.params.paramsWheel2.S = item[3][0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            this.params.DList2 = item;
            break;
          }
        }
      }
    },
    /*六孔板轮End*/

    /*四椭圆辐轮Start*/
    initFourOvalSpokeWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsFourOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsFourOvalSpokeWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD1 = item[2];
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            this.judgeF(this.params.paramsWheel1, parseFloat(this.params.n1), 4, 1);
            break;
          }
        }
      }
    },
    initFourOvalSpokeWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsFourOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsFourOvalSpokeWheelTypeD[i];
        if (item[0] === d) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD2 = item[2];
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            this.judgeF(this.params.paramsWheel2, parseFloat(this.params.n2), 4, 2);
            break;
          }
        }
      }
    },
    /*四椭圆辐轮End*/

    /*六椭圆辐轮Start*/
    initSixOvalSpokeWheelD1() {
      let d = parseFloat(this.params.diameter1);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel1.d = d;
      this.params.paramsWheel1.B = B;
      this.params.paramsWheel1.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSixOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsSixOvalSpokeWheelTypeD[i];
        if (d >= item[0][0] && d <= item[0][1]) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD1 = item[2];
            this.params.paramsWheel1.D = this.optionSolidWheelD1[0];
            this.changeSolidWheelD1(this.params.paramsWheel1.D);
            this.judgeF(this.params.paramsWheel1, parseFloat(this.params.n1), 6, 1);
            break;
          }
        }
      }
    },
    initSixOvalSpokeWheelD2() {
      let d = parseFloat(this.params.diameter2);
      let B = parseFloat(this.params.wheelWidth);
      this.params.paramsWheel2.d = d;
      this.params.paramsWheel2.B = B;
      this.params.paramsWheel2.h = this.getWheelH(d);

      for(let i = 0; i < this.classParamsSixOvalSpokeWheelTypeD.length; i++) {
        let item = this.classParamsSixOvalSpokeWheelTypeD[i];
        if (d >= item[0][0] && d <= item[0][1]) {
          if (B >= item[1][0] && B <= item[1][1]) {
            this.optionSolidWheelD2 = item[2];
            this.params.paramsWheel2.D = this.optionSolidWheelD2[0];
            this.changeSolidWheelD2(this.params.paramsWheel2.D);
            this.judgeF(this.params.paramsWheel2, parseFloat(this.params.n2), 6, 2);
            break;
          }
        }
      }
    },
    /*六椭圆辐轮End*/

    findValue(arr, target) {
      let left = 0;
      let right = arr.length - 1;
      while (left <= right) {
        let mid = Math.floor((left + right) / 2);
        if (arr[mid] === target) {
          return arr[mid];
        } else if (arr[mid] < target) {
          left = mid + 1;
        } else {
          right = mid - 1;
        }
      }
      if(left <= 0 ) {
        return arr[0];
      } else if(left >= arr.length) {
        return arr[arr.length - 1];
      }
      // 近似数检查
      let closest = arr[left - 1];
      let diffLeft = Math.abs(target - arr[left - 1]);
      let diffRight = Math.abs(target - arr[left]);
      if (diffLeft < diffRight) {
        return closest;
      } else {
        return arr[left];
      }
    },
    findValueByValue(arr, target) {
      let left = 0;
      let right = arr.length - 1;
      while (left <= right) {
        let mid = Math.floor((left + right) / 2);
        if (arr[mid].value === target) {
          return arr[mid].value;
        } else if (arr[mid].value < target) {
          left = mid + 1;
        } else {
          right = mid - 1;
        }
      }
      if(left <= 0 ) {
        return arr[0].value;
      } else if(left >= arr.length) {
        return arr[arr.length - 1].value;
      }
      // 近似数检查
      let closest = arr[left - 1].value;
      let diffLeft = Math.abs(target - arr[left - 1].value);
      let diffRight = Math.abs(target - arr[left].value);
      if (diffLeft < diffRight) {
        return closest;
      } else {
        return arr[left].value;
      }
    },
    findValueByKey(arr, target) {
      let left = 0;
      let right = arr.length - 1;
      while (left <= right) {
        let mid = Math.floor((left + right) / 2);
        if (parseFloat(arr[mid].key) === parseFloat(target)) {
          return arr[mid].value;
        } else if (parseFloat(arr[mid].key) < parseFloat(target)) {
          left = mid + 1;
        } else {
          right = mid - 1;
        }
      }
      if(left <= 0 ) {
        return arr[0].value;
      } else if(left >= arr.length) {
        return arr[arr.length - 1].value;
      }
      // 近似数检查
      let closest = arr[left - 1].value;
      let diffLeft = Math.abs(target - parseFloat(arr[left - 1].key));
      let diffRight = Math.abs(target - parseFloat(arr[left].key));
      if (diffLeft < diffRight) {
        return closest;
      } else {
        return arr[left].value;
      }
    },
    close(){
      beltDriveCommand.closeActiveCmd();
    },
  },
  watch: {
    'params.drivingWheelDiameterCoefficient': {
      handler(newVal, oldVal) {
        this.initBasicParams();
      },
    },
    'params.P': {
      handler(newVal, oldVal) {
        this.changeP();
      },
    },
    'params.n1': {
      handler(newVal, oldVal) {
        this.initBasicParams();
      },
    },
    'params.n2': {
      handler(newVal, oldVal) {
        this.initBasicParams();
      },
    },
    'params.elasticSlipCoefficient': {
      handler(newVal, oldVal) {
        this.initBasicParams();
      },
    },
    'params.wheelType1': {
      handler(newVal, oldVal) {
        this.initParamsWheelD1();
      },
    },
    'params.wheelType2': {
      handler(newVal, oldVal) {
        this.initParamsWheelD2();
      },
    },
    'params.diameter1': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
        this.initParamsWheelD1();
      },
    },
    'params.diameter2': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
        this.initParamsWheelD2();
      },
    },
    'params.paramsWheel1.D': {
      handler(newVal, oldVal) {
        this.changeParamsWheelD1();
      },
    },
    'params.paramsWheel2.D': {
      handler(newVal, oldVal) {
        this.changeParamsWheelD2();
      },
    },
    'params.wheelWidth': {
      handler(newVal, oldVal) {
        this.initParamsWheelD1();
        this.initParamsWheelD2();
        this.changeParamsWheelD1();
        this.changeParamsWheelD2();
      },
    },
    'params.initCenterDistance': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
    'params.workingCondition': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
    'params.workingMode': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
    'params.workingLength': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
    'params.normalTensionStressOfBelt': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
    'params.beltCount': {
      handler(newVal, oldVal) {
        this.calculateAllParams();
      },
    },
  }
}
</script>

<style scoped>
.wrap {
    font-size: 12px;
}
</style>